<?php
/**
 * request.class.php
 *
 * Request params wrapper
 *
 * @version:	0.4
 * @package:	core
 * @author:	alex_ez
 * @created:	15 nov 2008
 *
 * @link:	http://src.qfox.ru/
 *
 * @copyright:	(c) 2008 flamebox.ru. All rights reserved.
 */

function trailingslashit($string) {
    return untrailingslashit($string) . '/';
}

function untrailingslashit($string) {
    return rtrim($string, '/');
}

function base_url() {
    $request = request::instance();
    $port = $request->getPort();

    if($port == 80)
        return sprintf('%s://%s/', $request->getScheme(), $request->getHost());

    return sprintf('%s://%s:%d/', $request->getScheme(), $request->getHost(), $port);
}

function site_url($uri) {
    $base_url = base_url();

    if(is_array($uri))
        $uri = implode('/', $uri);

    if($uri == '')
        return trailingslashit($base_url);
    else
        return trailingslashit($base_url) . trailingslashit(trim($uri, '/'));
}

function current_url(){
	return request::instance()->getUrl();
}

